//- 先去这个pug文件中找
extends shopHead_nav.pug

block append pageStyle
	link(href="${relativePath}/static/css/shopping/shopIndex.css" rel="stylesheet" type="text/css")
	link(href="${relativePath}/static/css/shopping/materFinished.css" rel="stylesheet" type="text/css")
	link(href="${relativePath}/static/css/shopping/service.css" rel="stylesheet" type="text/css")

block matrialContent
	//- 成品材料内容
	div.matrialCon.layout
		p.allKinds
			| <a href="materIndex.html">首页 > </a>
			| <a href="industryServiceIndex.html">设备租赁</a>
		ul.installNav
			//- select.oneSelect
			//- 	option(value="") 请选择
			//- 	option 车辆出租
		div.meterialTabBox
			div.tabBtn
				div.left.fl
					span.current 综合
						i
					span 销量
						i
					span 距离
						i
					span 信誉
						i

		//- 行业服务发表需求列表
		div.demandList.clear
			ul.clear.designOne
				//- li
				//- 	a(href="javascript:;")
				//- 		img(src="${relativePath}/static/imgs/process-MG-01.png")
				//- 		div.demainBox
				//- 			div.fbDemain
				//- 				span.fl 发布需求
				//- 				i.fr 2173人付款
				//- 			p.release 跟据自己的需求发布订单
				//- 			div.orderBox
				//- 				span.setCommon.chat 聊天
				//- 				span.setCommon.order.current 下单
				//- li
				//- 	a(href="javascript:;")
				//- 		img(src="${relativePath}/static/imgs/process-MG-02.png")
				//- 		div.demainBox
				//- 			div.fbDemain
				//- 				span.designName.fl 标识设计
				//- 				i.fr 11.11km
				//- 			p.release
				//- 				a.address.fl(href="javascript:;") 郑东新区商鼎路
				//- 				span.follow.current.fr 已关注
				//- 			div.orderBox
				//- 				span.setCommon.chat 聊天
				//- 				span.setCommon.order 下单

	//- 广告设计模板
	script#carMB(type="text/html")
		| {{set design = data.result}}
		| {{each design arr index}}
		| <li {{if index ==0}}class="active"{{/if}} id="{{arr.member_id}}" cateid="{{arr.parent_id}}" cate_id="{{arr.category_id}}">
		|	<a class="bbxImg" href="javascript:;" style="background: url('{{arr.avatar_img}}') no-repeat 0 center">
		|	</a>
		|	<div class="demainBox">
		|		<div class="fbDemain"{{if arr.is_identification == 2}}class="designName"{{/if}}>
		|			<a href="javascript:;" class="fl"> {{arr.company_name}}</a>
		|		</div>
		|		<p class="release">
		|			<a class="address fl" (href="javascript:;")>
		|			{{if arr.cur_city == ""}}
		|			无
		|			{{else}}
		|				{{arr.cur_city}}
		|			{{/if}}
		|			</a>
		|			{{if index !=0}}
		|				{{if arr.is_concern == 1}}
		|			<span class="follow current fr"> 已关注 </span>
		|				{{else}}
		|			<span class="follow fr"> 关注</span>
		|				{{/if}}
		|			{{/if}}
		|		</p>
		|		{{if index !=0}}
		|		<div class="orderBox">
		|			<span class="setCommon chat"> 聊天</span>
		|			<span class="setCommon order"> 下单</span>
		|		</div>
		|		{{/if}}
		|	</div>
		| </li>
		| {{/each}}

	//- 分页
	div.pageBox
		nav.pageNav
			div.paginationOne.page

block pageScript

	script.
		$(function(){
			$("#hyfw1").addClass("active");
			$("#cpcl").click(function(){
				window.location.href='materFinished.html';
			});
			$("#index").click(function(){
				window.location.href='materIndex.html';
			});
			$(".left span").click(function(){
				$(this).addClass("current").siblings().removeClass("current");
			});


			//- 点击商品收藏
			$(".btnProduct .sc").on("click",function(){
				if($(this).hasClass("current")) {
					$(this).removeClass('current');
				}else{
					$(this).addClass('current');
				}
			})

			/*点击关注*/
			$(".designOne").on("click",".release .follow",function(){
				var $this = $(this);
				if($(this).hasClass("current")) {
					$(this).text("关注");
					$(this).removeClass('current');
					$.post(shopIp+"/Concern/concern",{
						userToken:token,
						concern_id:$this.closest("li").attr("id")
					},function(data) {
						layer.msg(data.msg);
					});
				}else{
					$(this).text("已关注");
					$(this).addClass('current');
					$.post(shopIp+"/Concern/concern",{
						userToken:token,
						concern_id:$this.closest("li").attr("id")
					},function(data) {
						layer.msg(data.msg);
					});
				}
			})
			//- 车辆租赁获取二级菜单列表
			function one(){
				$.post(shopIp+"/category/subCategory",{
					userToken:token,
					type_id:5
				},function(data) {
					var liData = data.data.goods_category;
					for(var i=0;i<liData.length;i++) {
						if( i==0 ) {
							var ele = '<li class="active" id="'+liData[i].id+'"><a href="javascript:;"> '+liData[i].name+'</a></li>';
						}else{
							var ele = '<li id="'+liData[i].id+'"><a href="javascript:;"> '+liData[i].name+'</a></li>';
						}
						$(".installNav").append(ele);
					}
				});
			}
			one();
			//- 点击安装列表
			$(".installNav").on("click","li",function() {
				$(this).addClass("active").siblings().removeClass("active");
				designList(1,$(this).attr("id"));
			});
			//- 设计综合列表
			function designList(pageNum,id,parent_id) {
				//- 广告设计列表获取
				$.post(shopIp+"/category/lists_api",{
					userToken:token,
					category_id:id,
					parent_id:parent_id,
					type:5,
					page:pageNum,
					size:10
				},function(data) {
					var design = template("carMB",data);
					$(".designOne").html(design);
					$(".page").html("").pagination({
						pageCount : data.data.pageCount,
						current : pageNum,
						keepShowPN : true,
						count : 2,
						homePage : "1",
						endPage : data.data.pageCount,
						coping : true,
						prevContent : "< 上一页",
						nextContent : "下一页 >",
						callback : function(page) {
							designList(page.getCurrent(),id,parent_id);
						}
					});
				})
			};
			designList(1,"","");

			//- 点击第一个发布需求
			$(".designOne").on("click","li:first-child .fbDemain a",function() {
				if($(this).closest("li").attr("cateid") == "586") {
					window.location.href = "carNeeds.html?parent_id="+$(this).closest("li").attr("cateid")+"&id="+$(this).closest("li").attr("id")+"&cate_id="+$(this).closest("li").attr("cate_id");
				} else{
					window.location.href = "equiNeeds.html?parent_id="+$(this).closest("li").attr("cateid")+"&id="+$(this).closest("li").attr("id")+"&cate_id="+$(this).closest("li").attr("cate_id");;
				}
			})
			//- 点击除了第一个列表进详情
			$(".designOne").on("click","li .fbDemain a:not(:first)",function() {
				window.location.href = "rightOrder.html?id="+$(this).closest("li").attr("id")+"&parent_id="+$(this).closest("li").attr("cateid")+"&cate_id="+$(this).closest("li").attr("cate_id");;
			})
			//- 点击下单
			$(".designOne").on("click",".orderBox .order",function() {
				window.location.href = "equiNeeds.html?parent_id="+$(this).closest("li").attr("cateid")+"&id="+$(this).closest("li").attr("id")+"&cate_id="+$(this).closest("li").attr("cate_id");;
			})
		})